package util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
public class VipUtil extends VipCount {
	public VipCount getvips(){
		ArrayList<Integer> a = getVip();
		VipCount vip = new VipCount(
				a.get(0),
				a.get(1),
				a.get(2),
				a.get(3),
				a.get(4),
				a.get(5)
				);
		return vip;
	}
	public ArrayList<Integer> getVip(){
		ArrayList<Integer> a = new ArrayList<Integer>();
		try{
			Connection conn = DBUtil.getConnection();
			Statement sta = conn.createStatement();
			String sql = "select * from vipcount";
			ResultSet set = sta.executeQuery(sql);
			while(set.next()){
				a.add(Integer.parseInt(set.getString(1)));
				a.add(Integer.parseInt(set.getString(2)));
				a.add(Integer.parseInt(set.getString(3)));
				a.add(Integer.parseInt(set.getString(4)));
				a.add(Integer.parseInt(set.getString(5)));
				a.add(Integer.parseInt(set.getString(6)));
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return a;
	}
	public void updatevip(VipCount vip){
		try{
			Connection conn = DBUtil.getConnection();
			Statement sta = conn.createStatement();
			String sql = "update vipcount set lifa = "+vip.getLifa() + ", ranfa = " + vip.getRanfa()+",tanfa = "+vip.getTanfa()+",tanran = "+vip.getTanran()+",huli = " + vip.getHuli() + ", xifa = "+ vip.getXifa();
			sta.execute(sql);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
